import { createApp, computed, toRaw } from 'vue'
import './style.css'
import App from './App.vue'
import router from './router'
import { store } from './store'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import PanelHead from './components/panelHead.vue'

const app = createApp(App)
const localData = JSON.parse(localStorage.getItem('pz_v3pz'))
//动态路由添加
if (localData) {
  store.commit('dynamicMenu', localData.menu.routerList)
  const routerList = computed(() => store.state.menu.routerList)
  toRaw(routerList.value).forEach(element => {
    router.addRoute('main', element)
  });
}


// 全局注入顶部面板组件
app.component('PanelHead', PanelHead)
app.use(store)
app.use(router)

app.mount('#app')

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}



